package com.example.wto.viewpagertest01;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class ClassRoom implements ConvertToJsonObject
{
	private List<DayOfWeek> weekList=new ArrayList<DayOfWeek>();//�����б�
    ClassRoomBean bean=null;
    public ClassRoom()
    {
       
    }
    
    public ClassRoom(ClassRoomBean bean)
    {
    	this.bean=bean;
    }
    public ClassRoomBean getBean()
	{
		return bean;
	}


	public void setBean(ClassRoomBean bean)
	{
		this.bean = bean;
	}


	public List<DayOfWeek> getWeekList()
    {
        return weekList;
    }

    public void setWeekList(List<DayOfWeek> weekList)
    {
        this.weekList = weekList;
    }

	public String toJsonObject()
    {
        JSONObject jsonObject=new JSONObject();
        JSONArray jsonArray=new JSONArray();
        try
        {
        	jsonObject.put("college_id",bean.getCollegeID());
            jsonObject.put("college_name",bean.getCollegeName());
            jsonObject.put("s_id",bean.getS_id());
            jsonObject.put("s_name",bean.getS_name());
            jsonObject.put("campus_id",bean.getCampusID());
            jsonObject.put("campus_name",bean.getCampusName());
            jsonObject.put("teach_bulid_id",bean.getTeachBuildID());
            jsonObject.put("teach_build_name",bean.getTeachBuildName());
            jsonObject.put("class_room_id",bean.getClassRoomID());
            jsonObject.put("class_room_name",bean.getClassRoomName());
            
            DayOfWeek weekDay=null;
            for(int i=0;i<weekList.size();i++)
            {
                weekDay=weekList.get(i);
                JSONObject jso=new JSONObject();
                jso.put("weekName",weekDay.getWeekName());
                JSONArray jsonArrayCourse = new JSONArray();
                List<Course> courseList=weekDay.getCourseList();
                for(int j=0;j<courseList.size();j++)
                {
                	jsonArrayCourse.put(courseList.get(j).getCourseName());
                }
                jso.put("course", jsonArrayCourse);
                jsonArray.put(jso);
            }
            jsonObject.put("courses",jsonArray);
        } catch (JSONException e)
        {
            e.printStackTrace();
        }
        return jsonObject.toString();
    }
}
